<!--
 * 日志管理--操作日志--详细
 * @author: hexiaozhen
 * @since: 2023-09-26
 * addEditUser.vue
-->
<template>
  <a-modal
    v-model:visible="visibleModal"
    title="操作日志详细"
    title-align="start"
    width="900px"
    :mask-closable="false"
    draggable
    @close="handleCancel"
  >
    <a-descriptions
      :data="proxy.$commontFn.descriptionsDataFn(formItems, formData)"
      :column="2"
      size="large"
      layout="horizontal"
      bordered
    >
    </a-descriptions>
    <template #footer>
      <a-button @click="handleCancel">关闭</a-button>
    </template>
  </a-modal>
</template>

<script setup>
import { reactive, ref, toRefs, getCurrentInstance } from 'vue'
const { proxy } = getCurrentInstance()
const props = defineProps({
  // 表单json配置项
  visible: {
    type: Boolean,
    default: false,
  },
  rowData: {
    type: Object,
    default: () => {
      return {
        type: '',
      }
    },
  },
  typeOptions: {
    type: Array,
    default: () => {
      return []
    },
  },
  statusOptions: {
    type: Array,
    default: () => {
      return []
    },
  },
})
const { visible, rowData, typeOptions, statusOptions } = toRefs(props)
const emit = defineEmits(['update:visible'])
let visibleModal = ref(false) // 弹窗显示与隐藏
visibleModal.value = visible.value

// 取消
const handleCancel = () => {
  visibleModal.value = false
  emit('update:visible', false)
}

// 表单配置
const formItems = reactive([
  { name: 'title', label: '操作模块' },
  { name: 'operUrl', label: '请求地址' },
  { name: 'loginInfo', label: '登录信息' },
  { name: 'requestMethod', label: '请求方式' },
  { name: 'method', label: '操作方法', span: 24 },
  { name: 'operParam', label: '请求参数', span: 24 },
  { name: 'jsonResult', label: '返回参数', span: 24 },
  { name: 'status', label: '操作状态' },
  { name: 'operTime', label: '操作时间' },
  { name: 'errorMsg', label: '异常信息', span: 24 },
])
let formData = reactive({ ...rowData.value })
const businessType = typeOptions.value.filter((item) => {
  return item.value === formData.businessType.toString()
})
formData.title = formData.title + ' / ' + (businessType.length ? businessType[0].label : '')
const status = statusOptions.value.filter((item) => {
  return item.value === formData.status.toString()
})
formData.status = status.length ? status[0].label : ''
formData.loginInfo = formData.operName + ' / ' + formData.operIp
</script>
